USE [DTP]
GO

/****** Object:  StoredProcedure [dbo].[CreateEventCard]    Script Date: 09/14/2010 11:47:03 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[CreateAccidentCard]	
AS
BEGIN
	SET NOCOUNT ON;
	INSERT INTO t_AccidentCards (
					Deleted
					) 
	VALUES (0);
	SELECT SCOPE_IDENTITY();
END
GO


create PROCEDURE [dbo].[UpdateAccidentCardSharedInfo]
	@id BIGINT,

	@fabula					NVARCHAR(max),
	[regionCode] [int] NULL,
    [accidentDateTime] [datetime2](7)  NULL,        
    [operationType] [int] NULL,
    [cardRegistrationNumber] [int] NULL,
    [checksum] [int] NULL,
    [cardReportNumber] [int] NULL,
    
    [streetName] [int] NULL,
    [streetCategory] [int] NULL,
    [house] [nvarchar](10) NULL,
    [distanceM] [int] NULL,
    [distanceKm] [int] NULL,
    [centerOfPopulationName] [int] NULL,
    [centerOfPopulationStatus] [int] NULL,
    [roadCategory] [int] NULL,
    [region] [int] NULL,
    [roadName] [int] NULL,
    [roadValue] [int] NULL,
    
    [participentAmmount] [int] NULL,
    [vehicleAmmount] [int] NULL,
    [accidentScheme] [int] NULL,
    [accidentType] [int] NULL,

    [additionalInfo] [nvarchar](1024) NULL,
    
    [centerStripWidth] [int] NULL,
    [sidewalkWidth] [int] NULL,
    [roadsideWidth] [int] NULL,
    [roadWidth] [int] NULL,
    [engineeringStructure] [int] NULL,
    [planElement] [int] NULL,

    [coverType] [int] NULL,
    [roadState] [int] NULL,
    [lightType] [int] NULL,
    [whetherType] [int] NULL,
    [roadCondition] [int] NULL,
    [Deleted] [bit] NOT NULL
	@mishap_date				DATETIME2,
	@category_id				INT,
	@information_source			INT,
	@address_region_id		SMALLINT,
	@address_regionpart_id	SMALLINT,
	@address_city_id			SMALLINT,
	@address_town_id			SMALLINT,
	@address_street_id		SMALLINT,
	@address_house			NVARCHAR(20) = NULL,
	@address_building		NVARCHAR(20) = NULL,
	@address_flat			NVARCHAR(20) = NULL,
	@reporter_lastname		NVARCHAR(100) = NULL,
	@reporter_firstname		NVARCHAR(100) = NULL,
	@reporter_fathername		NVARCHAR(100) = NULL,
	@reporter_dob			DATE = NULL,
	@reporter_phone			NVARCHAR(50) = NULL,
	@reporter_company_name	NVARCHAR(100) = NULL,
	@reporter_additional_info NVARCHAR(max) = NULL,
	@kusp					NVARCHAR(50) = NULL,
	@reporter_passport_info_no		VARCHAR(12) = NULL,
	@reporter_passport_info_given	NVARCHAR(200) = NULL,
	@reporter_passport_info_given_date DATE = NULL
	
AS
BEGIN
	SET NOCOUNT ON;

    UPDATE dbo.t_event_cards 
    SET fabula = @fabula, mishap_date = @mishap_date, category_id = @category_id, information_source = @information_source,
		address_region_id = @address_region_id, address_regionpart_id = @address_regionpart_id,
		address_city_id = @address_city_id, address_town_id = @address_town_id, address_street_id = @address_street_id,
		address_house = @address_house, address_building = @address_building, address_flat = @address_flat,
		reporter_lastname = @reporter_lastname, reporter_firstname = @reporter_firstname, reporter_fathername = @reporter_fathername,
		reporter_dob = @reporter_dob, reporter_phone = @reporter_phone, reporter_company_name = @reporter_company_name,
		reporter_additional_info = @reporter_additional_info, kusp = @kusp, reporter_passport_info_no = @reporter_passport_info_no,
		reporter_passport_info_given = @reporter_passport_info_given, reporter_passport_info_given_date = @reporter_passport_info_given_date
    WHERE id = @id;
END

GO